import sys
from urllib import urlopen
import cElementTree as et

url = "http://www.lut.fi/~saffe/geo/busstops.xml"

busns = "http://lprwilima.lappeenranta.fi/busstops/2006/04"
geons = "http://geo"

def getBusStops(url=url):
   qs = u"{%s}stop" % busns
   data = et.parse(urlopen(url)).findall(qs)
   stops = {}
   for s in data:
      stops[s.attrib["wilma-id"]] = {"name":s.text, "lat":s.attrib["{%s}lat" % geons], "lon":s.attrib["{%s}lon" % geons]}
   return stops
   

if __name__ in ("__main__", "busstops"):
   stops = getBusStops()
   print stops["PA117"]